<template>
	<view class="main">
		<Head></Head>
		<view class="box-top">
			<view :class="['top-left',num=='1' ? 'txt-box' :''] " style="margin-right: 1px;" @tap="boxChang('1')">记录时间
			</view>
			<view :class="['top-left',num=='2' ? 'txt-box' :''] " @tap="boxChang('2')">内容</view>
		</view>
		<view class="box-bottom">
			<scroll-view style="height: 100%;" scroll-y="true" :scroll-top="scrollTop" @scroll="scroll">
				<view class="bottom-untls" v-for="(item,index) in VitaList" :key="index">
					<view class="untls-txt1">{{item.rcdtime}}</view>
					<view class="xian"></view>
					<view class="untls-txt2">{{item.remark}}</view>
				</view>
			</scroll-view>
		</view>
		<view class="btm">
			<u-button type="primary" class="btn2" text="生命体征录入" color="#7ADFCA" @tap="nav"></u-button>
			<u-button type="primary" class="btn3" text="退出" color="#FF6E91" @tap="cancel"></u-button>
		</view>
		<suspension-ball :isShow="false"></suspension-ball>
	</view>
</template>

<script>
	import Head from '../../components/html/head.vue'
	import suspensionBall from '../../components/html/xuanfuqiu.vue'
	import {
		EMR_Nusing_GetVitaList
	} from '../../api/user.js'
	import {
		mapMutations,
		mapState
	} from "vuex";
	export default {
		components: {
			Head,
			suspensionBall
		},
		data() {
			return {
				value: '',
				show: false,
				num: '1',
				VitaList: [],
				scrollTop: 0,
			}
		},
		onLoad() {
			this.EMR_Nusing_GetVitaListFun()
		},
		watch: {
			deleteObj: {
				// deep: true,
				handler(newval) {
					this.EMR_Nusing_GetVitaListFun()
				},
			}
		},
		computed: {
			...mapState('user', ['userInfo', 'passObj', 'scanningArray', 'deleteObj'])
		},
		methods: {
			...mapMutations("user", ["set_siveShow", "set_vitalShow"]),
			nav() {
				this.set_siveShow(false)
				this.set_vitalShow(true)
				uni.navigateBack({
					delta: 1, //返回层数，2则上上页
				})
			},
			cancel() {
				this.set_siveShow(false)
				uni.navigateBack({
					delta: 1, //返回层数，2则上上页
				})
			},
			scroll(e) {
				//记录scroll  位置
				this.oldScrollTop = e.detail.scrollTop
			},
			boxChang(e) {
				this.num = e
				this.EMR_Nusing_GetVitaListFun()
			},
			async EMR_Nusing_GetVitaListFun() {
				try {
					this.scrollTop = this.oldScrollTop
					//当视图渲染结束 重新设置为0
					this.$nextTick(() => {
						this.scrollTop = 0
					});
					uni.showLoading({
						title: '加载中...', //显示的文字
						// duration: 3000, //显示多少时间，默认1500毫秒
						icon: "loading", //自定义显示的图标，默认成功success，错误error,加载loading，不显示图标是none
						mask: true
					})
					const user = uni.getStorageSync('userInfo')
					const obj = uni.getStorageSync('deleteObj')
					const data = {
						HosKind: user.hoscode,
						lmrn: obj.MRN,
						iseries: obj.SERIES,
						kind: this.num == "1" ? '记录时间' : '内容',
						sOperdept: user.HosKind,
						sOperJp: user.sPassword
					}
					const res = await this.$http.EMR_Nusing_GetVitaList(data)
					if (res) {
						this.VitaList = res
						uni.hideLoading();
					}
				} catch (e) {
					//TODO handle the exception
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.main {
		width: 100%;
		height: 100vh;
		background: #F9F9F9;
		overflow: hidden;
	}

	.box-top {
		display: flex;
		align-items: center;

		.top-left {
			width: 50%;
			// padding: 14px 48px;
			background: #6BC6CC;
			font-size: 18px;
			font-family: SourceHanSansCN-Medium, SourceHanSansCN;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 46px;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.txt-box {
			&:before {
				content: " ";
				width: 18px;
				height: 18px;
				background: url('../../static/img/xingxing.svg') no-repeat;
				margin-right: 10rpx;

			}
		}
	}

	.box-bottom {
		padding: 10px 10px 0;
		height: calc(100% - 235px);
		overflow-y: scroll;

		.bottom-untls {
			background: #FFFFFF;
			box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.06);
			border-radius: 4px;
			display: flex;
			align-items: center;
			padding: 12px 10px;
			margin-bottom: 10px;

			.untls-txt1 {
				font-size: 15px;
				font-family: SourceHanSansCN-Normal, SourceHanSansCN;
				font-weight: 400;
				color: #333333;
				line-height: 23px;
				// margin-right: 19px;
				width: 50%;
			}

			.xian {
				width: 1px;
				height: 26px;
				background: #E9F5F6;
			}

			.untls-txt2 {
				font-size: 16px;
				font-family: SourceHanSansCN-Normal, SourceHanSansCN;
				font-weight: 400;
				color: #333333;
				line-height: 24px;
				// padding-left: 10px;
				width: 50%;
				text-align: center;
			}

		}
	}

	.btm {
		display: flex;
		align-items: center;
		padding: 20px 10px;

		.u-reset-button ::v-deep .u-button__text {
			font-size: 18px !important;
			font-family: SourceHanSansCN-Medium, SourceHanSansCN;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 27px;
		}

		.btn2 {
			box-shadow: 0px 2px 6px 0px #6AC8B5;
			margin-right: 11px;

		}

		.btn3 {
			box-shadow: 0px 2px 6px 0px #ff6e91;
			letter-spacing: 14px;
			padding-left: 14px;
			width: 60%;
		}
	}
</style>
